/*
 * @Author: your name
 * @Date: 2021-02-04 11:07:40
 * @LastEditTime: 2021-02-25 00:06:09
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \myproject\src\utils\ls.js
 */
// 存入token
export const setToken = (payload) => {
  try {
    return localStorage.setItem('hm-token', JSON.stringify(payload))
  } catch (e) {
    console.log('检查jason格式')
    return {}
  }
}
// 取出token
export const getToken = () => {
  try {
    // console.log('gettoken')
    return JSON.parse(localStorage.getItem('hm-token'))
  } catch (e) {
    console.log('检查jason格式')
    return {}
  }
}
// 删除token
export const removeToken = () => {
  return localStorage.removeItem('hm-token')
}

// 存入History
export const setHistory = (payload) => {
  try {
    return localStorage.setItem('historyList', JSON.stringify(payload))
  } catch (e) {
    console.log('检查jason格式')
    return {}
  }
}
// 取出
export const getHistory = () => {
  try {
    return JSON.parse(localStorage.getItem('historyList'))
  } catch (e) {
    console.log('检查jason格式')
    return {}
  }
}
// 删除
export const delHistory = () => {
  return localStorage.removeItem('historyList')
}
